package com.sskj.uboex.ui.activity;


import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.flyco.tablayout.SegmentTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.sskj.common.adapter.MyFragmentPagerAdapter;
import com.sskj.lib.Constans;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;
import com.sskj.uboex.R;
import com.sskj.uboex.presenter.FinanceRecordActivityPresenter;

import java.util.ArrayList;
import java.util.Arrays;

import butterknife.BindView;

@Route(path = RConfig.APP_FINANCE_RECORD)//资产记录
public class FinanceRecordActivity extends BaseActivity<FinanceRecordActivityPresenter> {
    @BindView(R.id.segmentTabLayout)
    SegmentTabLayout segmentTabLayout;
    @BindView(R.id.viewPager)
    ViewPager viewPager;
    String code = "USDT";
    @Autowired
    int pos = 0;

    @Override
    protected int getLayoutResId() {
        return R.layout.app_activity_finance_record;
    }

    @Override
    public FinanceRecordActivityPresenter getPresenter() {
        return new FinanceRecordActivityPresenter();
    }

    @Override
    protected void initView() {
        ARouter.getInstance().inject(this);
        setTitle("资产记录");
        String[] strings = {"充币明细", "提币明细", "账单明细"};
        segmentTabLayout.setTabData(strings);
        segmentTabLayout.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {

                viewPager.setCurrentItem(position);
            }

            @Override
            public void onTabReselect(int position) {

            }
        });
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add((Fragment) ARouter.getInstance().build(RConfig.APP_FRAGMENT_RECHARGE_AND_WITHDRAW)
                .withString(Constans.CODE, code)
                .withString(Constans.TYPE, "1")
                .navigation());
        fragments.add((Fragment) ARouter.getInstance().build(RConfig.APP_FRAGMENT_RECHARGE_AND_WITHDRAW)
                .withString(Constans.CODE, code)
                .withString(Constans.TYPE, "2")
                .navigation());
        fragments.add((Fragment) ARouter.getInstance().build(RConfig.APP_FRAGMENT_FINANCE_RECORD)
                .withString(Constans.CODE, code)
                .navigation());
        viewPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), Arrays.asList(strings), fragments));
        viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                super.onPageSelected(position);
                segmentTabLayout.setCurrentTab(position);
            }
        });
        segmentTabLayout.setCurrentTab(pos);
    }


}
